package cn.rulian.base.auth.bo;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;

import cn.rulian.base.common.bo.BaseBo;
import lombok.Getter;
import lombok.Setter;


/** 
 * Description: 用户
 */
@Getter
@Setter

@Entity
@Table(name = "base_auth_user")
public class User extends BaseBo{

	public static final String DEV="devAdmin"; //开发用户
	
	public static final String POST_KF="客服"; //岗位标记（模拟，暂不用）
	
	@ManyToOne
	@JoinColumn(name = "organ_id")
	private Organ organ; //机构
	
	@Column(length = 50)
	private String name; //姓名
	
	@Column(length = 20)
	private String tel; //手机号
	
	@Column(length = 20)
	private String post; //岗位
	
	@Column(length = 50)
	private String loginName; //登录名
	
	@Column(length = 100)
	private String password; //密码
	
	private Boolean enabled; //是否可用
	
	@JsonIgnore
	@ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
	@JoinTable(name="base_auth_role_user",
			joinColumns=@JoinColumn(name="userId", referencedColumnName="id"), 
			inverseJoinColumns=@JoinColumn(name="roleId", referencedColumnName="id"))
	private List<Role> roleList;

	private String roleNames; //角色名称（显示用）
	
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") 
	private Date addTime; //增加时间
	
	private Integer orderNum; //排序号
	
}